//
//  YuYUTableViewController.m
//  guahao
//
//  Created by 蒋梦婷 on 16/10/3.
//  Copyright © 2016年 osx. All rights reserved.
//

#import "YuYUTableViewController.h"
#import "GuaHaoInfoModel.h"
#import "MJExtension.h"
#import "GuaHaoInfoCell.h"

@interface YuYUTableViewController ()

@end

@implementation YuYUTableViewController

- (NSMutableArray *)models{
    
    NSMutableArray* modelsArray=[NSMutableArray array];
    //字典数组转模型数组 mjExtension框架
    modelsArray=[GuaHaoInfoModel mj_objectArrayWithKeyValuesArray:_models];
    // modelsArray=[HsptCellModel mj_objectArrayWithKeyValuesArray:HsptInfoArray];
    _models=modelsArray;
    
    //        NSLog(@"--------------\n %@ \n-------------------",_models);
    //}
    return _models;
    
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"xianhua"] style:UIBarButtonItemStylePlain target:self action:@selector(backToLeftView)];
    
}
- (void)backToLeftView{
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
#warning Incomplete implementation, return the number of sections
    return 1;
}

#pragma mark - Table view data source

//返回行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section    {
    return  self.models.count;
}

//返回cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath  {
    GuaHaoInfoCell *cell = [GuaHaoInfoCell cellWithTableView:tableView];
    cell.model=self.models[indexPath.row];
    
    // Configure the cell...
    
    return cell;
}
//返回行高
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    GuaHaoInfoModel * model=self.models[indexPath.row];
    CGFloat need=model.h;
    return need;
}
//预估高度
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath  {
    return 200;
}


#warning 选择这一行后调用
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
    
    GuaHaoInfoCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
    
    // NSString *urlstr = [NSString stringWithFormat:@"department?HospitalName=%@",cell.model.HospitalName];
    
    
    
    
    
    
    
    
    NSString *urlstr = @"doctor";
    NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:cell.model.HospitalName,@"HospitalName",cell.model.DepartmentName,@"DepartmentName", nil];
    
    
    
    NSLog(@"%@",urlstr);
//    [[GHNetWorkTools sharedTools] requestDataWith:GET urlString:urlstr parameters:NULL finishedBlock:^(id result, NSError *error) {
//        NSLog(@"%@",result);
//        
//        DoctorViewControllerTableViewController* need=[[DoctorViewControllerTableViewController alloc]init];
//        
//        need.models = [result valueForKey:@"Doctor"];
//        need.title = cell.model.DepartmentName;
//        //设置返回按钮样式
//        self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
//        [self.navigationController pushViewController:need animated:YES];
//        
//        
//        
//    }];
    
    
    
    
    
    
    
    
    //创建DepartmentViewController,push进导航控制器
    // DoctorViewControllerTableViewController * need=[[DoctorViewControllerTableViewController alloc]init];
    //设置返回按钮样式
    //  self.navigationItem.backBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
    // [self.navigationController pushViewController:need animated:YES];
}

@end
